package com.timesheet.gui.efforttracker.providers;

import com.example.timesheet.uitl.DateUtil;
import com.example.timesheet.uitl.TaskUtils;
import com.timesheet.server.common.models.view.EffortTrackerViewModel;

import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;

public class EffortTableLabelProver implements ITableLabelProvider,
		IColorProvider {

	@Override
	public void addListener(ILabelProviderListener listener) {

	}

	@Override
	public void dispose() {

	}

	@Override
	public boolean isLabelProperty(Object element, String property) {

		return false;
	}

	@Override
	public void removeListener(ILabelProviderListener listener) {

	}

	@Override
	public Image getColumnImage(Object element, int columnIndex) {

		return null;
	}

	@Override
	public String getColumnText(Object element, int columnIndex) {
		if (element instanceof EffortTrackerViewModel) {
			EffortTrackerViewModel model = (EffortTrackerViewModel) element;

			if (model != null
					&& TaskUtils.FULLDAY_LEAVE.equals(model.getTaskType())) {
				model.setTaskPhase("");
				model.setStatus("");
				model.setTaskNo("");
			}

			switch (columnIndex) {
			case 0:
				return DateUtil.getDateAsDDMMYY(model.getDayDate()) + "("
						+ DateUtil.getDayAsFullString(model.getDayDate()) + ")";
			case 1:
				return model.getTaskType();
			case 2:
				return model.getTaskNo();
			case 3:
				return model.getTaskPhase();
			case 4:
				return "" + model.getHours();
			case 5:
				return "" + model.getStatus();
			case 6:
				return "" + model.getTaskDescription();
			default:
				return "No result";
			}
		}
		return null;
	}

	@Override
	public Color getForeground(Object element) {
		return null;
	}

	@Override
	public Color getBackground(Object element) {
		// return Display.getCurrent().getSystemColor(SWT.COLOR_GRAY);
		return null;
	}

}
